﻿using Microsoft.EntityFrameworkCore;
using WorldmeServer.Attributes;
using WorldmeServer.DTO.用户相关;
using WorldmeServer.Models.Base;
using WorldmeServer.Models.材质相关;
using WorldmeServer.Models.用户相关;
using WorldmeServer.Services.Database;
using WorldmeServer.Utils;

namespace WorldmeServer.Services.Business.用户相关
{
    [ScopedRegistration]
    public class UserService
    {
        private readonly MySqlContext mysql;
        private readonly RedisService redis;
        public UserService(MySqlContext mysql, RedisService redis)
        {
            this.mysql = mysql;
            this.redis = redis;
        }

        public async Task<ServiceResult<User>> GetUser(string id)
        {
            var user = await mysql.Users.FirstOrDefaultAsync();
            if (user == null)
            {
                return ServiceResult<User>.Fail("用户不存在");
            }
            return ServiceResult<User>.Success(user);
        }

        public async Task<ServiceResult<User>> Update(UpdateUserDTO dto)
        {
            throw new NotImplementedException();
        }


    }
}
